/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2011.03.31                                          *
 *                                                                       *
 *************************************************************************/

//declaration header
#include "COMMON/info/WriterInfo.h"

//C++ headers
#include <sstream>

//COMMON headers
#include "COMMON/info/InfoManager.h"
#include "COMMON/tbox/LogMessage.h"
#include "COMMON/tbox/MathUtilities.h"

namespace FreeMAPs
{

WriterInfo::WriterInfo(
    const std::string& object_name):
    Parent            ("base_information", object_name),
    d_writer_types("VTK")
{
}



WriterInfo::~WriterInfo()
{
    this->clear();
}



void
WriterInfo::clear()
{
}



bool
WriterInfo::check_all_info_db (
        const InputDatabase* db)
{
    if( !db->key_exists("writer_types") )
    {
        FREEMAPS_ERROR("in \"writer_info\", can not find  \"writer_types\" \n");
        return false;
    }
    if( !db->is_string("writer_types") )
    {
        FREEMAPS_ERROR("in \"writer_info\", \"writer_types\" should be string \n");
        return false;
    }

    return true;
}



void
WriterInfo::get_from_input (
        const InputDatabase* db)
{
    this->active_verbose_mode (0);

    this->prepare_for_use (db);

    //check parameter
    db->insert_allowable_key_with_items ("writer_types");

    db->check_allowable_keys ();

    /*
     * build writer_types
     */
    if (db->key_exists ("writer_types"))
    {
//        db->check_optional_key ("writer_types", DataType::STRING, true, false);
//        d_writer_types = db->get_string_with_default ("writer_types", d_writer_types);
    }
}



std::ostream&
operator << (
    std::ostream& os,
    const WriterInfo& rhs)
{
    //writer_types = "VTK", "ASCII"

    os << "writer_info" << RTN_FLAG << "{" << std::endl;
    os << LogMessage::get_prefix (ONE_TAB) << "writer_types = " << "\"VTK\", \"ASCII\""<< RTN_FLAG;

    os << "}";

    return os;
}

} // namespace FreeMAPs
